<template>
  <div id="app">
    <el-container>
      <el-header>
        <el-menu 
          mode="horizontal" 
          :router="true" 
          class="menu" 
          :default-active="$route.path"
        >
          <el-menu-item index="/configs">
            <el-icon><Document /></el-icon>
            <span>MQ配置</span>
          </el-menu-item>
          <el-menu-item index="/failed-messages">
            <el-icon><Warning /></el-icon>
            <span>失败消息</span>
          </el-menu-item>
        </el-menu>
      </el-header>
      
      <el-main>
        <!-- 路由视图 -->
        <router-view />
      </el-main>
    </el-container>
  </div>
</template>

<script setup>
import { reactive } from 'vue'
import { Document, Warning } from '@element-plus/icons-vue'

// 全局状态管理
const globalStore = reactive({
  error: null,
  success: null,
  loading: false,
  setError(message) {
    this.error = message
    this.success = null
  },
  setSuccess(message) {
    this.success = message
    this.error = null
  },
  clearError() {
    this.error = null
  },
  clearSuccess() {
    this.success = null
  },
  clearMessages() {
    this.error = null
    this.success = null
  }
})

// 提供全局状态给子组件
import { provide } from 'vue'
provide('globalStore', globalStore)
</script>

<style>
#app {
  font-family: 'Helvetica Neue', Helvetica, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: #303133;
}

body {
  margin: 0;
  padding: 0;
  background-color: #f5f7fa;
}

.el-header {
  padding: 0;
  height: auto;
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  z-index: 100;
  position: relative;
}

.el-menu {
  width: 100%;
}

.el-main {
  padding: 20px;
  min-height: calc(100vh - 60px);
}
</style>